//
//  SPScanAfterViewController.m
//  Sampux
//
//  Created by rzm on 16/9/29.
//  Copyright © 2016年 rzm. All rights reserved.
//

#import "SPScanAfterViewController.h"
#import "SampuxWiFiGuideViewController.h"

@interface SPScanAfterViewController ()

@end

@implementation SPScanAfterViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    [self.navigationItem setHidesBackButton:YES];

      // Do any additional setup after loading the view.
}

- (void)setupSubView
{
    CGFloat font = 8.;
    if (IS_IPHONE_4_OR_LESS) {
        font = 12.;
    }else if (IS_IPHONE_5_OR_LESS)
    {
        font = 12.;
    }else if (IS_IPHONE_6)
    {
        font = 14.;
    }else
    {
        font = 16.;
    }
    UIImageView *backImageView = [[UIImageView alloc]initWithFrame:self.view.bounds];
    backImageView = backImageView;
    [self.view addSubview:backImageView];
    backImageView.userInteractionEnabled = YES;
    backImageView.image = imageNamed(@"backImg");
    
    _label = [UILabel createLabel];
    [backImageView addSubview:_label];
    _label.frame = CGRectMake(self.view.width/2 - Sampux6WScale(SampuxCustomW)/2, Sampux6WScale(60) + 64, Sampux6WScale(SampuxCustomW), Sampux6HScale(SampuxCustomH));
    _label.font = THFont(font);
    _label.textAlignment = NSTextAlignmentCenter;
    //    label.text = @"设备ID号:";
    _label.textColor = THWhiteAlplaColor(0.6);
    UIButton *_setWifiBtn = [UIButton createButtonWithTitle:@"连接网络" frame: CGRectMake(self.view.width/2 - Sampux6WScale(345/2)/2, _label.bottom + Sampux6HScale(30) , Sampux6WScale(345/2), Sampux6HScale(SampuxCustomH)) titleFont:THFont(17) titleColor:THDeFaultBlueColor];
    [backImageView addSubview:_setWifiBtn];
    [_setWifiBtn setCorner:_setWifiBtn.height/2];
    _setWifiBtn.layer.borderWidth = 1;
    _setWifiBtn.layer.borderColor = THWhiteAlplaColor(0.6).CGColor;
    [_setWifiBtn addTarget:self action:@selector(confirmBtnClick) forControlEvents:UIControlEventTouchUpInside];
}

- (void)setNumberString:(NSString *)numberString
{
    [self setupSubView];
    _numberString = numberString;
    self.label.text = [NSString stringWithFormat:@"设备ID：%@",_numberString];
}

- (void)confirmBtnClick
{
    SampuxWiFiGuideViewController *documentVC = [[SampuxWiFiGuideViewController alloc]init];
    [self.navigationController pushViewController:documentVC animated:YES];
    documentVC.numbStr = self.numberString;
//    documentVC.numbStr = seriesNumberStr;
}

- (void)viewWillAppear:(BOOL)animated
{
    [super viewWillAppear:YES];
    SampuxCustomNavController *nav = (SampuxCustomNavController *)self.navigationController;
    nav.titleStr = @"添加设备";    
}

@end
